<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function ZZR (food) {
            this.time = 48;
            this.eat = function() {
                console.log(food);
            }
        }
        function A (a) {
            // call 召唤 当前的方法不足已完成某个功能时 召唤别的函数帮你完成
            // ZZR.call(this, 'hlt')
            // apply 应用 将ZZR的属性和方法应用于A 修改ZZR的this指向 变成 A的this
            // ZZR.apply(this, ['hm'])
            // bind不会立即执行 需要调用 别的和call一样
            this.myEat = ZZR.bind(this, 'lc');
            this.name = 'qhy';
            this.age = a;
            this.coding = function() {
                console.log('写代码');
            }
        }
        let z1 = new ZZR()

        let a1 = new A(18);
        console.log(a1);
    </script>
</body>
</html>